package club.jdiy.utils.poi;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;

/**
 * JDiy 数据导出支持接口
 *
 * @author ziquee(子秋) QQ号:39886616 主页: http://www.jdiy.club
 * @version 20201016
 */
public interface Export {
    /**
     * 添加导出数据集.
     *
     * @param dataset 数据集合
     */
    void addData(Collection<?> dataset);

    /**
     * HTTP导出并下载
     *
     * @param request  HttpServletRequest
     * @param response HttpServletResponse
     * @param fileName 导出显示的文件名（扩展名可以省略）
     * @throws IOException ex
     */
    void output(HttpServletRequest request, HttpServletResponse response, String fileName) throws IOException;

    /**
     * 导出为文件.
     *
     * @param file 目标文件
     * @throws IOException ex
     */
    void output(File file) throws IOException;

    /**
     * 导出到输出流
     *
     * @param out 流
     * @throws IOException ex
     */
    void output(OutputStream out) throws IOException;
}
